<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/assets/css/bootstrap.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/assets/css/bootstrap-responsive.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/assets/css/bootstrap.min.css" type="text/css" media="screen" />
<? Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/assets/js/jquery-ui.js");?>
<? Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/assets/js/jquery.min.js");?>

<script type="text/javascript">
		$(document).ready(function(){    
		$("#btn1").click(function(){ $.post("setting/Editsetting", {      
		ADMIN_PERMIT_LIST: $("#ADMIN_PERMIT_LIST").val(),
		MIKROTIK_HOST: $("#MIKROTIK_HOST").val(),
		MIKROTIK_PASSWORD: $("#MIKROTIK_PASSWORD").val(),
		MIKROTIK_PORT: $("#MIKROTIK_PORT").val()
		
		},     
		   function(data){ $("#showajax").html(data);    
		     }  );    
      }); 
    });
</script> 
 
 <style type="text/css">
 fieldset.scheduler-border {
  	width:inherit; /* Or auto */
    border: 1px groove #ddd !important;
    padding:0 10px; /* To give a bit of padding on the left and right */
    margin: 0 0 1.5em 0 !important;
    -webkit-box-shadow:  0px 0px 0px 0px #000;
            box-shadow:  0px 0px 0px 0px #000;
}

legend.scheduler-border {
    width:inherit; /* Or auto */
    padding:0 10px; /* To give a bit of padding on the left and right */
    border-bottom:none;

}
#showajax {
	color: red;
}
 </style>
 
<div class="container">
<form class="form-horizontal">
<fieldset>
    <legend>Configs</legend>
    
<?php $sql = "SELECT * FROM configs";
		$dataReader = Yii::app()->db->createCommand($sql)->query();
		
		foreach ($dataReader as $data){
			$keyname = $data['keyname'];
			$keyvalue = $data['keyvalue'];
			
			$str_key .= $data['keyname'].',';
			$str_val .= $data['keyvalue'].',';
			
			?>

  <?php
		}
			$str_key = substr($str_key,0,-1);
			$arr_key = explode(",",$str_key);
			$str_val = substr($str_val,0,-1);
			$arr_val = explode(",",$str_val);
		echo	$ADMIN_PERMIT_LIST =$arr_val[0];
			$MIKROTIK_HOST =$arr_val[1];
			$MIKROTIK_PASSWORD =$arr_val[2];
			$MIKROTIK_PORT =$arr_val[3];
		
?>
			
			<div class="control-group">
		    <label class ="control-label"><?php echo $arr_key[0] ?></label>
		    <div class="controls">
		      <input type="text" class="form-control" id="ADMIN_PERMIT_LIST" value="<?php echo $arr_val[0] ?>">
		      		</div>
		  	</div>
		  	<div class="control-group">
		    <label class ="control-label"><?php echo $arr_key[1] ?></label>
		    		<div class="controls">
		      <input type="text" class="form-control" id="MIKROTIK_HOST" value="<?php echo $arr_val[1] ?>">
		      		</div>
		  	</div>
			<div class="control-group">
		    <label class ="control-label"><?php echo $arr_key[2] ?></label>
		    		<div class="controls">
		      <input type="text" class="form-control" id="MIKROTIK_PASSWORD" value="<?php echo $arr_val[2] ?>">
		      		</div>
		  	</div>
		  	<div class="control-group">
		    <label class ="control-label"><?php echo $arr_key[3] ?></label>
		    		<div class="controls">
		      <input type="text" class="form-control" id="MIKROTIK_PORT" value="<?php echo $arr_val[3] ?>">
		      		</div>
		  	</div>
		  	<div class="control-group">
	    		<div class="controls">
	     			 <div id="showajax"></div>
	      		</div>
		  	</div>
		  	<div class="control-group">
		    
		    		<div class="controls">
		      <button type="button" id="btn1"  class="btn btn-default">Save</button>
		      		</div>
		  	</div>
	</fieldset>
</form>
	<div id="showajax" ></div> 
</div>
